# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: team/kde <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-applications
pkgname=kpimtextedit
pkgver=23.08.4
pkgrel=0
pkgdesc="Advanced text editor which provide advanced html feature"
# armhf blocked by extra-cmake-modules
arch="all !armhf"
url="https://api.kde.org/kdepim/kpimtextedit/html"
license="LGPL-2.0-or-later AND GPL-2.0-or-later"
depends_dev="
	grantlee-dev
	kcodecs5-dev
	kconfig5-dev
	kconfigwidgets5-dev
	kcoreaddons5-dev
	kemoticons5-dev
	ki18n5-dev
	kiconthemes5-dev
	kio5-dev
	kwidgetsaddons5-dev
	kxmlgui5-dev
	qt5-qtbase-dev
	qt5-qtspeech-dev
	sonnet5-dev
	syntax-highlighting5-dev
	"
makedepends="
	$depends_dev
	extra-cmake-modules
	qt5-qttools-dev
	samurai
	"
checkdepends="xvfb-run"
_repo_url="https://invent.kde.org/pim/kpimtextedit.git"
source="https://download.kde.org/stable/release-service/$pkgver/src/kpimtextedit-$pkgver.tar.xz"
subpackages="$pkgname-dev $pkgname-lang"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_DESIGNERPLUGIN=ON
	cmake --build build
}

check() {
	cd build

	# kpimtextedit-plaintext-textgotolinewidgettest,
	# kpimtextedit-composerng-richtextcomposertest and
	# kpimtextedit-composerng-richtextcomposercontrolertest require OpenGL
	# kpimtextedit-texttospeech-texttospeechwidgettest requires texttospeech
	# kpimtextedit-texttospeech-texttospeechactionstest and
	# kpimtextedit-grantleebuilder-texthtmlbuildertest are broken
	local skipped_tests="kpimtextedit-("
	local tests="
		plaintext-textgotolinewidget
		texttospeech-texttospeechwidget
		texttospeech-texttospeechactions
		composerng-richtextcomposer
		composerng-richtextcomposercontroler
		grantleebuilder-texthtmlbuilder
		"
	for test in $tests; do
		skipped_tests="$skipped_tests|$test"
	done
	skipped_tests="$skipped_tests)test"
	CTEST_OUTPUT_ON_FAILURE=TRUE xvfb-run ctest -E "$skipped_tests"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}
sha512sums="
e6c13fc7b919776dda0bebbbb3eb4607ff752002e5308438da594f9838c053081ad88f375c4333c058c86b1c1e1a9e5f04ee122e55c5b3e0913e09487de1ce5e  kpimtextedit-23.08.4.tar.xz
"
